package com.ruoyi.purchase.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.purchase.domain.InspectionResult;
import com.ruoyi.purchase.service.IInspectionResultService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 检验指标结果Controller
 * 
 * @author ruoyi
 * @date 2025-10-31
 */
@RestController
@RequestMapping("/purchase/result")
public class InspectionResultController extends BaseController
{
    @Autowired
    private IInspectionResultService inspectionResultService;

    /**
     * 查询检验指标结果列表
     */
    @PreAuthorize("@ss.hasPermi('purchase:result:list')")
    @GetMapping("/list")
    public TableDataInfo list(InspectionResult inspectionResult)
    {
        startPage();
        List<InspectionResult> list = inspectionResultService.selectInspectionResultList(inspectionResult);
        return getDataTable(list);
    }

    /**
     * 导出检验指标结果列表
     */
    @PreAuthorize("@ss.hasPermi('purchase:result:export')")
    @Log(title = "检验指标结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InspectionResult inspectionResult)
    {
        List<InspectionResult> list = inspectionResultService.selectInspectionResultList(inspectionResult);
        ExcelUtil<InspectionResult> util = new ExcelUtil<InspectionResult>(InspectionResult.class);
        util.exportExcel(response, list, "检验指标结果数据");
    }

    /**
     * 获取检验指标结果详细信息
     */
    @PreAuthorize("@ss.hasPermi('purchase:result:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(inspectionResultService.selectInspectionResultById(id));
    }

    /**
     * 新增检验指标结果
     */
    @PreAuthorize("@ss.hasPermi('purchase:result:add')")
    @Log(title = "检验指标结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InspectionResult inspectionResult)
    {
        return toAjax(inspectionResultService.insertInspectionResult(inspectionResult));
    }

    /**
     * 修改检验指标结果
     */
    @PreAuthorize("@ss.hasPermi('purchase:result:edit')")
    @Log(title = "检验指标结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InspectionResult inspectionResult)
    {
        return toAjax(inspectionResultService.updateInspectionResult(inspectionResult));
    }

    /**
     * 删除检验指标结果
     */
    @PreAuthorize("@ss.hasPermi('purchase:result:remove')")
    @Log(title = "检验指标结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(inspectionResultService.deleteInspectionResultByIds(ids));
    }
}
